package com.example.demo.controller;


import com.example.demo.common.Result;
import com.example.demo.entity.SysSubject;
import com.example.demo.judge.entity.SubmissionVO;
import com.example.demo.service.SysSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ld&zjw
 * @since 2024-01-28
 */
@RestController
@RequestMapping("/subject")
public class SysSubjectController {

    @Autowired
    SysSubjectService sysSubjectService;

    @GetMapping("/{id}")
    public Result<?> getById(@PathVariable Long id){
        return Result.success(sysSubjectService.getById(id));
    }

    @PostMapping("/submit")
    public Result<?> submit(@RequestBody SubmissionVO submissionVO) throws Exception {
        return Result.success(sysSubjectService.submit(submissionVO));
    }


    @GetMapping
    public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "10") Integer pageSize,
                              @RequestParam(defaultValue = "") Integer questionId,
                              @RequestParam(defaultValue = "") String questionName,
                              @RequestParam(defaultValue = "") String questionType) {
        return Result.success(sysSubjectService.findPage(pageNum, pageSize, questionId, questionName, questionType));
    }
    @GetMapping("/getLangList")
    public Result<?> getLangList(){
        return Result.success(sysSubjectService.getLanguages());
    }
}

